<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  我是字体的演示

  <button id="btn1" size="12">按钮1</button>
  <button id="btn2" size="14">按钮2</button>
  <button id="btn3" size="16">按钮3</button>
  
  <script>
    var btn1 = document.getElementById('btn1');
    var btn2 = document.getElementById('btn2');
    var btn3 = document.getElementById('btn3');
    

    // btn1.onclick = function () {
    //   document.body.style.fontSize = '12px';
    // }
    // btn2.onclick = function () {
    //   document.body.style.fontSize = '14px';
    // }
    // btn3.onclick = function () {
    //   document.body.style.fontSize = '16px';
    // }


    // 创建一个函数，设置body的字体大小
    function makeFun(size) {
      return function () {
        document.body.style.fontSize = size + 'px';
      }
    }

    btn1.onclick = makeFun(12);
    btn2.onclick = makeFun(14);
    btn3.onclick = makeFun(16);
    
  </script>
</body>
</html>